// ----------------------------------------------------------------------------------
// Microsoft Developer & Platform Evangelism
// 
// Copyright (c) Microsoft Corporation. All rights reserved.
// 
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 
// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES 
// OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// ----------------------------------------------------------------------------------
// The example companies, organizations, products, domain names,
// e-mail addresses, logos, people, places, and events depicted
// herein are fictitious.  No association with any real company,
// organization, product, domain name, email address, logo, person,
// places, or events is intended or should be inferred.
// ----------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.ServiceModel.Channels;

namespace SL.IdentityModel.Protocols.WSTrust
{
    /// <summary>
    /// inherits from BodyWriter, used to write RequestSecurityToken message body
    /// </summary>
    internal class WSTrustRequestBodyWriter : BodyWriter
    {
        private RequestSecurityToken _requestSecurityToken;

        /// <summary>
        /// creates an instance of the class
        /// </summary>
        /// <param name="requestSecurityToken">RequestSecurityToken instance to be used to create the message</param>
        public WSTrustRequestBodyWriter( RequestSecurityToken requestSecurityToken )
            : base( true )
        {
            _requestSecurityToken = requestSecurityToken;
        }

        /// <summary>
        /// Writes contents of message body
        /// </summary>
        /// <param name="writer">XmlDictionaryWriter to write message to</param>
        protected override void OnWriteBodyContents( XmlDictionaryWriter writer )
        {
            WSTrust13SerializationHelper serializationHelper = new WSTrust13SerializationHelper();

            serializationHelper.WriteXml( _requestSecurityToken, writer );
        }
    }
}